#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<algorithm>

using namespace std;

namespace zy
{
	template<class Iterator,class Ref,class Ptr>
	class Reverse_Iterator
	{
	public:
		typedef Reverse_Iterator<Iterator, Ref, Ptr> Self;

		Reverse_Iterator(Iterator it)
			:_it(it)
		{}

		Ref operator*()
		{
			Iterator tmp(_it);
			return *(--tmp);
		}

		Ptr operator->()
		{
			return &(operator*());
		}

		Self& operator++()
		{
			--_it;
			return *this;
		}

		Self operator++(int)
		{
			Self tmp(*this);
			--_it;
			return tmp;
		}

		Self& operator--()
		{
			++_it;
			return *this;
		}

		Self operator--(int)
		{
			Self tmp(*this);
			_it++;
			return tmp;
		}

		bool operator!=(const Self& x)
		{
			return _it != x._it;
		}

	private:
		Iterator _it;
	};
}



